package com.xiaobu.go;

import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;

public class StepDetector implements SensorEventListener
{
	private StepService mStepService;
	
    public StepDetector(StepService stepService)
    {
    	mStepService = stepService;
    }
    
    @Override
    public void onAccuracyChanged(Sensor sensor, int accuracy)
    {
    }
    
    @Override
    public void onSensorChanged(SensorEvent event)
    {
        Sensor sensor = event.sensor;
        
        synchronized (this)
        {
            if (sensor.getType() == Sensor.TYPE_ACCELEROMETER)
            {
            	mStepService.action(event);
            }
        }
    }
}